<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.jeecgframework.web.system.pojo.base.ZyCinemaEntity" %>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>附加任务</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  <script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
	 <script type="text/javascript" src="plug-in/jquery/jquerysession.js"></script>
  <script type="text/javascript">
  //编写自定义JS代码
  $(function(){
      $("#equipmentId").hide();
      });

      function clearEquip() {
          $("#cinemaId").show();
          $("#equipmentId").hide();
          $("#equipmentId").val("");
      $("#linkmanId").val('');
      $("#contactName").val('');
      $("#phone").val('');
      $("#contactEmail").val('');
      $("#equipBody").children().remove();
  }
  function clearEquipSN() {
      $("#cinemaId").hide();
      $("#equipmentId").show();

      $("#cinemaId").val("");
      $("#linkmanId").val('');
      $("#contactName").val('');
      $("#phone").val('');
      $("#contactEmail").val('');
      $("#equipBody").children().remove();
  }
  // var form=$("#formobj").Validform({
  //     ignoreHidden:true,
  //     postonce:true,
  //     showAllError : true,
  //     ajaxPost:true,
  //     tiptype:3,
  // })
function add() {
    var id = $("#cinemaId").val();
    var content = $("#content").val();
    var equipmentId = $("#equipmentId").val();
    id = decodeURI(id);
    content = decodeURI(content);
    // 调用formValidata 进行验证，并能阻止提交
    // if(!form.check(true)){
    //     form.submitForm(false);
    //     return;
    // }
    if (id == "" && equipmentId == "") {
        $.ajax({
            type: "post",
            data: {"id": id, "content": content},
            url: "cbsAttachTaskController.do?doAdd",
            success: function (data) {
                // alert("添加成功");
                jQuery.messager.confirm('提示:', '确定要添加吗?', function (event) {
                    if (event) {
                        tip("添加成功");
                        setTimeout("  addOneTab(\"附加任务\",'cbsAttachTaskController.do?cbsAttachTask');",1000);
                        setTimeout("closetab('新建待办任务')",1000);
                    } else {
                        // alert("你点击的是false");
                    }
                });
            }
        })
    }
    // window.location.href="cbsAttachTaskController.do?doAdd&id="+id+"&content="+content+"&equipmentId="+equipmentId;
    if (id != null && id != "") {
        $.ajax({
            type: "post",
            data: {"id": id, "content": content},
            url: "cbsAttachTaskController.do?doAdd",
            success: function (data) {
                jQuery.messager.confirm('提示:', '确定要添加吗?', function (event) {
                    if (event) {
                        // alertTip("添加成功","添加");
                        // window.location.href='cbsAttachTaskController.do?cbsAttachTask';
                        tip("添加成功");
                        //setTimeout("window.location.href='cbsAttachTaskController.do?cbsAttachTask'", 1000);
                        setTimeout("addOneTab('附加任务','cbsAttachTaskController.do?cbsAttachTask');",1000);
                        setTimeout("closetab('新建待办任务')",1000);
                    } else {
                        // alert("你点击的是false");
                    }
                });
            }
        })
    }
    if (equipmentId != null && equipmentId != "") {
        $.ajax({
            type: "post",
            data: {"equipment": equipmentId, "content": content},
            url: "cbsAttachTaskController.do?doAdd",
            success: function (data) {
                // setTimeout(send,1000)
                // window.location.href="cbsAttachTaskController.do?cbsAttachTask";
                // tip("添加成功");
                jQuery.messager.confirm('提示:', '确定要添加吗?', function (event) {
                    if (event) {
                        tip("添加成功");
                        //setTimeout("window.location.href='cbsAttachTaskController.do?cbsAttachTask'", 1000);
                        setTimeout("addOneTab('附加任务','cbsAttachTaskController.do?cbsAttachTask');",1000);
                        setTimeout("closetab('新建待办任务')",1000);
                        //  tip("添加成功123");
                    } else {
                        // alert("你点击的是false");
                    }
                });
            }
        })
    }

}
  function closeDialog() {
      $('#ReceiveFeedBackDialog').dialog('close');
  }
  function searchCinema() {
      $.dialog({
          content: "url:zyCinemaController.do?zyChooseCmOfContact",
          zIndex: 2100,
          title: '选择影院',
          lock: true,
          width: '400px',
          height: '500px',
          left: '85%',
          top: '65%',
          opacity: 0.4,
          init: function () {
              top.myWindow = window;
          },
          button: [{
              name: '确认',
              callback: function () {
				var cinemaName = $.session.get("cinemaName");
				$("#cinemaId").val(cinemaName);
                  $("#cinemaId").show();
                  $("#equipmentId").hide();
                  $("#equipmentId").val("");
              },
              focus: true
          }, {
              name: '返回',
              callback: function () {
              }
          }]
      });
  }
  function searchSn() {
      $.dialog({
          content: "url:cbsAttachTaskController.do?zyChooseSnOfContact",
          zIndex: 2100,
          title: '选择设备',
          lock: true,
          width: '400px',
          height: '500px',
          left: '85%',
          top: '65%',
          opacity: 0.4,
          init: function () {
              top.myWindow = window;
          },
          button: [{
              name: '确认',
              callback: function () {
                  var sn = $.session.get("equipmentSpareSn");
                  $("#equipmentId").val(sn);
                  $("#cinemaId").hide();
                  $("#equipmentId").show();
                  $("#cinemaId").val("");
              },
              focus: true
          }, {
              name: '返回',
              callback: function () {
              }
          }]
      });
  }
  </script>
 </head>
 <body>
  <t:formvalid layout="" dialog="false" formid="formobj" >
					<input id="id" name="id" type="hidden" value="${cbsAttachTaskPage.id }">
					<input id="createName" name="createName" type="hidden" value="${cbsAttachTaskPage.createName }">
					<input id="createBy" name="createBy" type="hidden" value="${cbsAttachTaskPage.createBy }">
					<input id="createDate" name="createDate" type="hidden" value="${cbsAttachTaskPage.createDate }">
					<input id="updateName" name="updateName" type="hidden" value="${cbsAttachTaskPage.updateName }">
					<input id="updateBy" name="updateBy" type="hidden" value="${cbsAttachTaskPage.updateBy }">
					<input id="updateDate" name="updateDate" type="hidden" value="${cbsAttachTaskPage.updateDate }">
	  <table class="nobordertable noborder" style="border: none;">
		  <tbody>
		  <tr>
			  <td class="al_r" width="30%">
				  <label>对象:</label>
			  </td>
			  <td width="70%">

					  <input id="equipmentId" name="equipmentId.sn"  type="text" style="width: 150px" class="inputxt">

				  <input id="cinemaId" name="cinemaId.id"
                         placeholder="其他"
                         readonly="readonly" type="text" style="width: 150px" class="inputxt">

					  	  <a  class="easyui-linkbutton" plain="true" icon="icon-search" onclick="searchCinema()">[选择影院]</a>
				  <%--<t:choose url="zyCinemaController.do?zyChooseCmOfContact" name="cinemaList" icon="" height="450px"--%>
							<%--title="选择影院" hiddenName="cinemaName" inputTextname="cinemaId.id" hiddenid="id"--%>
							<%--textname="name" fun="clearEquip"/>--%>
				  <%--<t:choose url="cbsAttachTaskController.do?zyChooseSnOfContact" name="equipmentSpareList" icon="" height="450px"--%>
							<%--title="选择设备序列号" hiddenName="equipmentSpareSn" inputTextname="equipmentId.sn" hiddenid="id"--%>
							<%--textname="sn" fun="clearEquipSN"/>--%>
				  <a href="#" class="easyui-linkbutton" plain="true" icon="icon-search" onclick="searchSn()">[选择设备]</a>
			  </td>
		  </tr>
		  <tr>
			  <td class="al_r" width="30%" valign="top">
				  <label>备注:</label>
			  </td>
			  <td width="70%">
				  <textarea style="width: 100%; height: 80px;" id="content" name="content"></textarea>
				  <span class="Validform_checktip"></span>
				  <label class="Validform_label" style="display: none;">姓名</label>
			  </td>
		  </tr>
		<tr>
			  <td colspan="2" style="text-align: center;">
				  <a href="#" onclick="add()" class="easyui-linkbutton l-btn">确认</a>
			  </td>
		  </tr>
		  </tbody>
	  </table>

		</t:formvalid>

  </div>
 </body>
 <script type="text/javascript">

 </script>
  <script src = "webpage/com/zybk/cbsattachtask/cbsAttachTask.js"></script>		